package com.tyf.common.vo;

/**
 * 
 * @ClassName: SaveRequest<br>
 * @Description: 保存请求前后端数据交互VO<br>
 * @author liutao<br>
 * @date 2016年10月22日上午9:16:22<br>
 *
 */
public class SaveRequest<M>{
	
	/**
	 * 页面类型 simple multi bill 
	 */
	private String pageType;
	
	/**
	 * 单表数据
	 */
	private SimpleSaveRequest<M> simplePage;
	
	/**
	 * 多表数据
	 */
	private MultiSaveRequest<M> multiPage;

	public String getPageType() {
		return pageType;
	}

	public void setPageType(String pageType) {
		this.pageType = pageType;
	}

	public SimpleSaveRequest<M> getSimplePage() {
		return simplePage;
	}

	public void setSimplePage(SimpleSaveRequest<M> simplePage) {
		this.simplePage = simplePage;
	}

	public MultiSaveRequest<M> getMultiPage() {
		return multiPage;
	}

	public void setMultiPage(MultiSaveRequest<M> multiPage) {
		this.multiPage = multiPage;
	}
	
	public static <T> SaveRequest<T> newSimpleＳaveRequest(){
		SaveRequest<T> m = new SaveRequest<T>();
		m.setPageType("simple");
		m.setSimplePage(SimpleSaveRequest.newSimpleSaveRequest());
		return m;
	}
	
	public static <T> SaveRequest<T> newMultiＳaveRequest(){
		SaveRequest<T> m = new SaveRequest<T>();
		m.setPageType("multi");
		m.setMultiPage(MultiSaveRequest.newMultiSaveRequest());
		
		return m;
	}
	
	/**
	 * 是否为空 单表数据为空 && 多表主表为null
	 * @return
	 */
	public boolean isEmpty(){
		return  (simplePage==null || simplePage.isEmpty()) && (multiPage==null || multiPage.getMaster()==null);
	}
}
